package day8;

import java.util.Scanner;

public abstract class drink {
    abstract void buy();
    abstract void add();
    abstract void variety();
    static Scanner sc = new Scanner(System.in);

}

class coffee extends drink {
    @Override
    void buy() {
        System.out.println("您选择了咖啡");
    }

    @Override
    void add() {
        System.out.println("请您选择配料 1.加糖 2.加奶 3.无添加");
        int choose = sc.nextInt();
        switch (choose){
            case 1:System.out.println("您已成功加糖");break;
            case 2:System.out.println("您已成功加奶");break;
            case 3:System.out.println("不添加");break;
        }
        System.out.println("咖啡购买成功！！！");
    }
    @Override
    void variety() {}
}

class water extends drink {
    void buy() {
        System.out.println("您选择了矿泉水，购买成功！！！");
    }

    @Override
    void add() {}

    @Override
    void variety() {}
}

class coke extends drink {
    void buy() {
        System.out.println("您选择了可乐");
    }

    @Override
    void add() {}

    @Override
    void variety() {
        System.out.println("请您选择品牌 1.可口可乐 2.百事可乐");
        int choose = sc.nextInt();
        switch (choose){
            case 1:System.out.println("您已成功获得可口可乐");break;
            case 2:System.out.println("您已成功获得百事可乐");break;
        }
        System.out.println("可乐购买成功！！！");
    }
}

class TestDrink{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        drink drink = null;
        System.out.println("请输入想要购买的饮料 1.咖啡 2.矿泉水 3.可乐");
        int choose=sc.nextInt();
        switch (choose){
            case 1:
                drink = new coffee();
                break;
            case 2:
                drink = new water();
                break;
            case 3:
                drink = new coke();
                break;
        }
        drink.buy();
        drink.variety();
        drink.add();
    }
}